﻿eventModule.controller("compareController", function ($scope, $location, EventService) {
    EventService.getVacancys().then(function (vacancys) { $scope.vacancys = vacancys }, function ()
    { alert('Error Occured.') });

    $scope.list2 = function () {
        var vacancy_id = $scope.item;
        EventService.getApplicants(vacancy_id).then(function (applicants) {
            $scope.applicants = applicants;
        }, function () { alert('Error occured.') });
    };


    $scope.compare = function (app) {
        var vacancy_id = $scope.item;
        var applicant1 = app[0];
        var applicant2 = app[1];
        var dataObj = { vacancy_id: vacancy_id, applicant1: applicant1, applicant2: applicant2 };

        EventService.compareApplicants(dataObj).then(function (data) { $scope.compobjects = data; }, function ()
        { alert('Error occured.'); });
       

        $scope.getProgress = function (value) {
            if (value == 4) {
                return "success";
            }
            else if (value == 3) {
                return "success";
            }
            else if (value == 2) {
                return "info";
            }
            else if (value == 1) {
                return "warning";
            }
            else {
                return "danger";
            }
        };


        $scope.getWidth = function (value) {
            if (value == 4) {
                return "100";
            }
            else if (value == 3) {
                return "70";
            }
            else if (value == 2) {
                return "40";
            }
            else if (value == 1) {
                return "20";
            }
            else {
                return "15";
            }
        };

    };

});